package cn.itsource.exam.service.impl;

import cn.itsource.exam.domain.LogInfo;
import cn.itsource.exam.mapper.LogInfoMapper;
import cn.itsource.exam.query.LogInfoQuery;
import cn.itsource.exam.service.LogInfoService;
import cn.itsource.exam.util.PageList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * Created by su on 2020/7/9.
 */
@Service
public class LogInfoServiceImpl implements LogInfoService {

    @Autowired
    private LogInfoMapper logInfoMapper;

    /**
     * 分页查询日志
     * @param paramIn
     * @return
     */
    @Override
    public PageList<LogInfo> getLogList(LogInfoQuery paramIn) {
        Integer count = logInfoMapper.countLogList(paramIn);
        if (count == null || "0".equals(count)){
            return  new PageList<LogInfo>();
        }
        return new PageList<LogInfo>(count,logInfoMapper.selectLogList(paramIn));
    }

    /**
     * 添加日志
     * @param logInfo
     */
    @Override
    public void addLogInfo(LogInfo logInfo) {
        if(logInfo != null){
            logInfo.setAddtime(new Date());
            logInfoMapper.insert(logInfo);
        }
    }
}
